import mainExport from './main-export';
import ComponentRenderer from './component-renderer';

function isComponent(Component) {
  return Boolean(typeof Component === 'function' && typeof Component.prototype.$mount === 'function');
}

function renderComponent(Component, props, htmlElement) {
  const component = new Component({
    propsData: props
  });
  component.$mount(htmlElement);
  return component;
}

const componentRenderer = new ComponentRenderer(isComponent, renderComponent);
export function get(Component = mainExport) {
  return componentRenderer.get(Component);
}
export function render(Component, props, htmlElement) {
  return componentRenderer.render(Component, props, htmlElement);
}
export function renderDefault(props, htmlElement) {
  return componentRenderer.renderDefault(props, htmlElement);
}
export { get as getComponent, get as getVueComponent, render as renderComponent, render as renderVueComponent, renderDefault as renderDefaultComponent, renderDefault as renderDefaultVueComponent };
export default renderDefault;